package main

import (
	//加载配置文件

	"log"
	"os/signal"
	"syscall"
	"work1/Config"
	_ "work1/DataBase"      //加载数据库
	"work1/Routes"          //加载路由
	service "work1/Service" //加载中间件

	"github.com/fvbock/endless"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.Use(service.Cors())
	Routes.Api(*r)

	s := endless.NewServer(":"+Config.Conf.Config.RunPort, r)
	signal.Ignore(syscall.SIGCHLD) //解决子进程未接收资源时变成僵尸进程
	err := s.ListenAndServe()
	if err != nil {
		log.Printf("server err: %v", err)
	}
}
